-
-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature - ChartView Pan Ended Delegate Call #3612
Conversation
…ially allow users to manually reset the hightlight values once panning is complete
Codecov Report
@@ Coverage Diff @@
## master #3612 +/- ##
==========================================
+ Coverage 29.94% 31.01% +1.06%
==========================================
Files 118 114 -4
Lines 13793 10483 -3310
==========================================
- Hits 4130 3251 -879
+ Misses 9663 7232 -2431
Continue to review full report at Codecov.
|
@liuxuan30 @petester42 This looks good to me! |
@@ -25,6 +25,9 @@ public protocol ChartViewDelegate | |||
/// - parameter highlight: The corresponding highlight object that contains information about the highlighted position such as dataSetIndex etc. | |||
@objc optional func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) | |||
|
|||
/// Called when a user stop highlighting values while panning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe your documentation needs to be updated. Shouldn't this read something like Called when a user stops panning
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
documentations need to be precise.
If many people want the delegate, we could merge.
I need this. Could u merged it ? |
Updated documentation in the code based on feedback
I updated the comment accordingly in the code, hope this helps :) |
@liuxuan30 Any update on this? |
These changes seem fine to me. If we’re going add delegate calls for gesture recognizes we should think about if we need them for all states of the gestures. Do people care about when a pan starts, or when it is ongoing? |
I'm open to merge.but as @petester42 said, if we add this, maybe we should add more? |
@liuxuan30 @AntonTheDev Great, thank you for moving this along! |
shall we add at least |
I believe the whole "didStartPanning" can be be assumed when "chartValueSelected" is called? Since you can't really start panning without making a callback. But once you take your finger off the screen, there was no way to tell that you did. The values do no unselect themselves |
I believe it'd be useful to make the callbacks similar to what we have for scrollview. And actually call them in pretty much the same situations as ScrollView does. |
I second making the delegate behave and be named as closely to UIScrollViewDelegate as possible. |
@AntonTheDev I'm ok to merge this, but it's just strange to me that we had didEnd without didStart. Though you might be able to know it get started through chartValueSelected, I think it's still different events. How about we append the |
Thanks for your awesome library ! It is really helping us :) |
@petester42 @jjatie how about this PR? shall we add a few more or just merge? I'm looking for a few PRs that can be merged soon and release a new version next week. |
Yes please! I'm running into this situation myself right now. chartValueSelected get called both on drag AND tap, but chartViewDidEndPanning only gets called when the user stops dragging. Definitely different use cases... Specifically, when this chart gets embedded inside a UIScrollView, we want to stop the UIScrollView from dragging when we are dragging on the chart. So one would think we can stop the UIScrollView from dragging on chartValueSelected, and restart it on chartViewDidEndPanning But the problem with this solution is that chartValueSelected is also called on a single tap on the chart. So when this happens, the UIScrollView stops dragging, but then we have no callback to restart it... And the user is stuck with an unscrollable UIScrollView until get actually drags on the Chart. Hope this was clear. I'm about to leave for the day, but if I don't hear from anyone back I'll probably make a pull request myself tomorrow. |
Issue Link 🔗
Over the years, every I have come to implement this library, i have found that 1 feature for me has always been missing which is the ability to know when the user stopped panning across a chart to display values on the fly, and have it reset once the user lets go. I've yet to find a clean solution other than modifying the library, and I have added some callback logic to the ChartViewDelegate
Goals ⚽
To be able to install this from the master repo, and not always have to fork it to add this exact feature./
Implementation Details 🚧
Added and optional method to the ChartViewDelegate to tell the delegate that the pan gesture has reached a cancelled / ended state
Testing Details 🔍
None, there are no specific tests. This should not effect the snapshotting at all, and has no effect on the existing codebase other than an optional callback.